<?php
/*
 * Created on Nov 28, 2007
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
?>
<?php
global $AppUI, $m, $tab;

require_once($AppUI->getModuleClass('quotations'));
// Get login object
$uid = $AppUI->user_id;
// Permission
$perms =& $AppUI->acl();
$canEdit = $perms->checkModule("quotations", 'edit');
$canDelete = $perms->checkModule("quotations", 'delete');

// Get company from $_GET object
$company_id = intval(dPgetParam($_GET, "company_id", 0));
// Prefix of quotations
$prefix = 'quote_';
// Init variable
$confirmedNum = 0;
$confirmedId = 6;
// path add Quotation
$pathRoot = './index.php?m=quotations';
$pathEditQuote = $pathRoot.'&a=quote_crud';
$pathViewQuote = $pathRoot.'&a=quote_view';
// Object
$obj = new CQuotations();
$status = dPgetParam($_GET, 'quote_status', null);
$result = $obj->getListQuotationByCusId($uid, $status, $company_id);
$final = $result;
// Calc confirmed number
$confirmedNum = sizeof($final) > 0 ? count($final[$prefix.'status']==$confirmedId) : 0;
$index = 0;
// Load Object Status
require_once($AppUI->getMasterDataClass('mdstatus'));
$objMD = new CMdStatus();
$statList = $objMD->getStatusList('Quotation');

?>
<form name="editFrm" action="./index.php?m=quotations" method="post">
<input type="hidden" id="dosql" name="dosql" value="do_quote_list"/>
<table width="100%" cellspacing="0" cellpadding="7" border="0" class="infopanel">
<tbody><tr>
	<td colspan="100%">
		<a href="<?=$pathRoot?>" alt="<?=$AppUI->_('Total')?>"><b><?=$AppUI->_('Total')?></b></a>: <?=sizeof($result)?>&nbsp;&nbsp;&nbsp;
		<b><?=$AppUI->_('Comfirmed')?></b>: <?=$confirmedNum?>&nbsp;&nbsp;&nbsp;
		<b><?=$AppUI->_('Other')?></b>: <?=sizeof($result) - $confirmedNum?>&nbsp;&nbsp;&nbsp;
	</td>
</tr>
</tbody>
</table>
<table width="100%" cellspacing="0" cellpadding="2" border="0" class="list">
	<tbody>
		<tr>
			<th style="width: 20px;" nowrap="nowrap">&nbsp;</th>
			<th style="width: 20px;"><image src="images/tick.gif" border="0"/></th>
			<th nowrap="nowrap"><?=$AppUI->_('Name')?></th>
			<th nowrap="nowrap"><?=$AppUI->_('Code')?></th>
			<th nowrap="nowrap"><?=$AppUI->_('Status')?></th>
			<th nowrap="nowrap"><?=$AppUI->_('Type')?></th>
			<th nowrap="nowrap"><?=$AppUI->_('Shipping Type')?></th>
			<th style="width: 20px;">&nbsp;</th>
			<!--th style="width: 20px;"><?=$AppUI->_('Set')?></th-->
		</tr>
		<?php if((is_null($final)) or (!is_array($final))):?>
		<tr class="second">
			<td colspan="100">No item available</td>
		</tr>
		<?php else: ?>
		<?php $index = 0; foreach($final as $subItem):?>
		<?php $index += 1;?>
		<tr class="<?= ($index%2)==0 ? 'first': 'second' ?>">
			<td align="center">
				<?php if($canEdit):?>
					<a href="<?=$pathEditQuote?>&quote_id=<?=intval($subItem[$prefix.'id'])?>"><img title="<?=$AppUI->_('Edit')?>" src="images/edit.gif" border="0"/></a></td>
				<?php endif;?>
			<td>
				<image src="images/<?=$subItem[$prefix.'completed'] > 0 ? 'tick.gif' : 'bullet.gif'?>" border="0"/>
			</td>
			<td><a href="<?=$pathViewQuote?>&quote_id=<?=intval($subItem[$prefix.'id'])?>"><b><?=$subItem[$prefix.'name']?></b></a></td>
			<td><?=$subItem[$prefix.'code']?></td>
			<td><?=$subItem['status_name']?></td>
			<td><?=$subItem['type_name']?></td>
			<td><?=$subItem['shipping_type_name']?></td>
			<td align="center">
				<?php if($canDelete):?>
				<a href="#" alt="" onclick="return deleteQuotation('<?=$subItem['name']?>', <?=$subItem['id']?>)"><img alt="<?=$AppUI->_('Delete')?>" src="images/delete.gif" border="0"/></a>
				<?php endif;?>
			</td>
			<!--td align="center"><input type="checkbox" name="quoteIdArr[]" value="<?=$subItem[$prefix.'id']?>"/></td-->
		</tr>
		<?php endforeach;?>
		<?php endif;?>
		<!--tr>
			<td colspan="100%" align="right">
				<?php if($canEdit):?>
				<input type="submit" name="updateStatus" value="update Status"/>
				<?= arraySelect($statList, 'quote_status', 'size="1" class="text" style="width: 135px;"', @$row->quote_status, true)?>
				<?php endif;?>
			</td>
		</tr-->
	</tbody>
</table>
</form>
